local require = require

local _M = {}

function _M.init_prometheus()
    local metric_prefix = "gateway_"

    _M.prometheus = require("utils.prometheus.prometheus").init("prometheus_metrics")
    --_M.metric_requests = _M.prometheus:counter("nginx_http_requests_total", "Number of HTTP requests", {"host","status","location"})
    --_M.metric_requests = _M.prometheus:counter("nginx_http_requests_total", "Number of HTTP requests", {"host","status"})
    _M.metric_latency = _M.prometheus:histogram("nginx_http_request_duration_seconds", "HTTP request latency", {"host","location"},{0.005,0.01,0.02,0.03,0.05,0.075,0.1,0.2,0.3,0.4,0.5,0.75,1,2,3,5,10,20,30,60,120,240})
    --_M.metric_connections = _M.prometheus:gauge("nginx_http_connections", "Number of HTTP connections", {"state"})
    _M.metric_response_sizes = _M.prometheus:histogram("nginx_http_response_size_bytes", "Size of HTTP responses", nil, {10,100,1000,10000,100000,1000000})
    _M.metric_bytes = _M.prometheus:counter("nginx_http_request_size_bytes", "Total size of incoming requests",{"host"})
end

function _M.clear()
    ngx.shared.prometheus_metrics:flush_all()
    return '{ok}'
end

return _M